<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>案例-1</title>
</head>

<body>
    <div id="fs">
        <div id="ad"></div>
        <div class="csstricky"></div>
    </div>
    <div class="height">
        高度占位
    </div>
    <style type="text/css">
        /*粘性定位，当用户滑动的距离超过top设置的值时，就相当于position:fixed定位
		当用户滑动的距离没超过top设置的值时，就相当于position:relative定位*/
        .csstricky {
            position: sticky;
            width: 30px;
            height: 30px;
            background: aqua;
            top: 50px;
        }

        #fs {
            height: 2000px;
            width: 100%;
        }

        #ad {
            height: 300px;
            width: 100%;
            background: black;
        }

        .height {
            width: 100px;
            height: 500px;
            background-color: antiquewhite;
        }
    </style>
</body>

</html>